

#ifndef MINION_H
#define MINION_H
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>
#include "Position.h"
#include "timer.h"
#include <iostream> //Can be removed after debuging
//Include OpenGL header files, so that we can use OpenGL

#include <iostream>
#include <stdlib.h>
using namespace std;

class Minion
{
public:

    Minion(Position);
    virtual ~Minion();
    Position const getPos();
    std::vector<Position> bestPath(const std::vector<Position>&,const Position);
     std::vector<Position> testPath(const std::vector<Position>&,const Position);
    std::vector<Position> const getBestPath();
     Position GetGoal();
    void Draw();

    void Update();
    void ModifyColor(float,float,float);
    bool HaveVisited(std::vector<Position>&, Position);
    bool ModifySpeed(double); // Cannot have a negetive speed. NEEDs to be discused more.
    double changeHealth(double);
    double const getHealth();
    void SlowStatus(float, double);
    void CheckSlowDuration();
    void SetIndex(int);
    void setPath(std::vector<Position>);
    timer statusTimer;
    double const GetSpeed();
    void SetGoal(Position);


protected:
void DrawLine();
 bool DLine;
    Position Pos;
    Position goal;
        std::vector<Position> MyBestPath;
    void SetPenalty(const Position, const Position, int&, int&, int&, int&);
    Position PrevPos; // Used for the pathfinding algorith.
      bool AtNextPoint(Position, Position, Position);

    double health;
    double maxHealth;
    double speed;
    float width,height,depth;
    int SpeedLocation;
    std::vector<double> speedVect; //1 is normal speed.
    float colorR, colorG, colorB;
    bool slow;
    double statusDuration;
    double tempspeed;

private:
    int index;

};
//So what I need to do is make the last value pushed onto the vector the length of the vector.
//I can't really do that becuase it is a position vector.
//What can I do then, go through each value and check to see if I went up down left or right?
//Looks like this may be my only choice.
class CompareDist
{
public:
    bool operator()(std::vector<Position>& P1, std::vector<Position>& P2) // Returns true if t1 is earlier than t2
    {
        //std::cout<< P1[P1.size() -1 ].Xpos << " ";
        bool answer = P1[P1.size() -1 ].Xpos > P2[P2.size()-1].Xpos;
        return answer; //Uses the Prioitized length.
    }
    //Not being used anymore
    ///Clean up
    double GetLength(std::vector<Position>& Points)  // Up: 1 Left :2 Right:2 Down : 5
    {
        double dist = 0;
        if(Points.size() < 1)
        {
            return dist;
        }
        for (int k = 0; k < Points.size()-1; k++)
        {
            if(Points[k+1].Xpos - Points[k].Xpos == -1) // if I moved Left
                dist += 2;
            else if(Points[k+1].Xpos - Points[k].Xpos == 1) // If I moved right.
                dist += 2;
            else if(Points[k+1].Ypos - Points[k].Ypos == 1) // If I moved up.
                dist += 1;
            else if(Points[k+1].Ypos - Points[k].Ypos == -1) // If I moved down.
                dist += 5;
        }
        return dist;
    }
};


#endif // MINION_H
